package cn.lili.modules.member.entity.vo;

import cn.lili.common.security.sensitive.Sensitive;
import cn.lili.common.security.sensitive.enums.SensitiveStrategy;
import cn.lili.common.utils.BeanUtil;
import cn.lili.modules.member.entity.dos.User;
import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotEmpty;
import java.time.LocalDateTime;
import java.util.Date;

/**
 * 用户VO
 *
 * @author Chopper
 * @version v1.0
 * 2022-08-23 20:49
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class UserVO {

    @ApiModelProperty(value = "用户ID")
    private String id;

    @ApiModelProperty(value = "用户用户名")
    private String username;

    @NotEmpty(message = "手机号码不能为空")
    @ApiModelProperty(value = "手机号码", required = true)
    @Sensitive(strategy = SensitiveStrategy.PHONE)
    private String mobile;

    @ApiModelProperty(value = "昵称")
    private String nickName;


    @Min(message = "用户性别参数错误", value = 0)
    @ApiModelProperty(value = "用户性别,1为男，0为女,-1 未知")
    private Integer sex;

    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "最后一次登录时间")
    private Date lastLoginDate;

    @CreatedDate
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "创建时间", hidden = true)
    private Date createTime;

    @ApiModelProperty(value = "头像")
    private String face;


    @ApiModelProperty(value = "是否启用")
    private Boolean enable = false;


    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @ApiModelProperty(value = "用户生日")
    private Date birthday;

    @ApiModelProperty(value = "飞语openId")
    @JSONField(serialzeFeatures= {SerializerFeature.WriteMapNullValue})
    private String openId;

    @ApiModelProperty(value = "飞语账号")
    @JSONField(serialzeFeatures= {SerializerFeature.WriteMapNullValue})
    private String account;

    @ApiModelProperty(value = "飞语昵称")
    @JSONField(serialzeFeatures= {SerializerFeature.WriteMapNullValue})
    private String fyName;

    @ApiModelProperty(value = "是否允许从1688采集商品")
    private Boolean grabAlibabaOpen=false;

    @ApiModelProperty("上级ID")
    private String parentId = "";

    @ApiModelProperty("上级昵称")
    private String parentUsername = "";

    @ApiModelProperty("下级人数")
    private Integer childCount;

    @ApiModelProperty("免密支付")
    private Boolean isPassword;

    @ApiModelProperty("上级绑定时间")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date parentBindTime;

    @ApiModelProperty("运营中心")
    private String operationName;

    public UserVO(User user) {
        BeanUtil.copyProperties(user, this);
    }

}
